﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;

// MobiLib, Copyright Mirosław M. Mączka.  All Rights Reserved. This code released under the terms of the Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)

namespace MobiLibrary
{
    public static class Extensions
    {
        //
        //==================================================================================================================================
        //
        public static bool EQ(this string a, string b)
        {
            return 0 == string.Compare(a, b, true);
        }
        public static bool SW(this string a, string b)
        {
            return a.StartsWith(b, StringComparison.CurrentCultureIgnoreCase);
        }
        public static bool EW(this string a, string b)
        {
            return a.EndsWith(b, StringComparison.CurrentCultureIgnoreCase);
        }
        //
        //
        public static void ForAll<T>(this IEnumerable<T> sequence, Action<T> action)
        {
            foreach (T item in sequence) action(item);
        }
        //
        //
        //
        //
        //
        public static void AddParam(this SqlParameterCollection p, string name, object value)
        {
            if (p.Contains(name)) p.RemoveAt(name);
            p.AddWithValue(name, value);
        }
        //
        //==================================================================================================================================
        //
    }//class
}//namespace
